<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<script type="text/javascript">
			window.onload=function(){
				//练习1 
				//1、创建两个UL标签
				var Ul1Node=document.body.appendChild(document.createElement("ul"));
				Ul1Node.id="ul1";
				var Ul2Node=document.body.appendChild(document.createElement("ul"));
				Ul2Node.id="ul2"; 
				//2、给ul标签中添加三个新的li标签
				for (var n =0 ;n<3;n++) {
					Ul1Node.appendChild(document.createElement("li"));
				}
				for (var n =0 ;n<3;n++) {
					Ul2Node.appendChild(document.createElement("li"));
				}
				//3在li标签中添加新的文本值  例如 苹果、香蕉、芒果
				var a=document.getElementsByTagName("li");
				var name =["苹果","香蕉","芒果","栗子","梨子","李子"]
					for (var n = 0 ;n<a.length;n++) {
						a[n].innerHTML=name[n];
					}
				//4、点击每个li标签，使其弹出该li标签中的水果名
					for(var n=0;n<a.length;n++){
						a[n].onclick=function(){
						alert(this.innerHTML);
						}
					}
			}
		</script>
	</head>
	<body>
	</body>
</html>
